

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Moe Wang">
  <meta name="keywords" content="">
  
    <meta name="description" content="FBI  WARNING！                                     五一假期已结束                不知道xdm都去哪里玩了？给点游玩的建议，我十一假期参考一下啊哈哈……   复习一下，上一篇我们首先讲了地图上的几大要素，包括点线面，然后了解了二维地图、三维地图中所使用的几大坐标系">
<meta property="og:type" content="article">
<meta property="og:title" content="【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（三）">
<meta property="og:url" content="https://moewang0321.github.io/2021/05/05/%E3%80%90%E4%B8%89%E7%BB%B4GIS%E5%8F%AF%E8%A7%86%E5%8C%96%E3%80%91%E5%9F%BA%E4%BA%8EVue+Cesium+Supermap%E5%AE%9E%E7%8E%B0%E6%99%BA%E6%85%A7%E5%9F%8E%E5%B8%82%EF%BC%88%E4%B8%89%EF%BC%89/index.html">
<meta property="og:site_name" content="moe_大杂烩">
<meta property="og:description" content="FBI  WARNING！                                     五一假期已结束                不知道xdm都去哪里玩了？给点游玩的建议，我十一假期参考一下啊哈哈……   复习一下，上一篇我们首先讲了地图上的几大要素，包括点线面，然后了解了二维地图、三维地图中所使用的几大坐标系">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/949a196a072149f9bd16b5006e014ce8~tplv-k3u1fbpfcp-zoom-crop-mark:3024:3024:3024:1702.awebp">
<meta property="article:published_time" content="2021-05-05T07:57:33.000Z">
<meta property="article:modified_time" content="2023-02-14T08:44:34.549Z">
<meta property="article:author" content="Moe Wang">
<meta property="article:tag" content="JavaScript">
<meta property="article:tag" content="Cesium">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/949a196a072149f9bd16b5006e014ce8~tplv-k3u1fbpfcp-zoom-crop-mark:3024:3024:3024:1702.awebp">
  
  
  
  <title>【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（三） - moe_大杂烩</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"moewang0321.github.io","root":"/","version":"1.9.4","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 5.4.2"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>moe_大杂烩</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（三）"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2021-05-05 15:57" pubdate>
          2021年5月5日 下午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          6.8k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          58 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（三）</h1>
            
            
              <div class="markdown-body">
                
                <pre><code class="hljs">                                    FBI  WARNING！
                                    五一假期已结束
               不知道xdm都去哪里玩了？给点游玩的建议，我十一假期参考一下啊哈哈……
</code></pre>
<blockquote>
<p>复习一下，上一篇我们首先讲了地图上的几大要素，包括点线面，然后了解了二维地图、三维地图中所使用的几大坐标系及其转换方式，最后大致讲了Cesium中的Viewer实体和Camera实体，对应着窗口和摄像机。接下来我们就进行实操，了解如何将点线面要素添加到我们的地球上。如果文章中有错误的话欢迎评论区指出，定当虚心请教并及时修改！</p>
</blockquote>
<h3 id="Entity实体"><a href="#Entity实体" class="headerlink" title="Entity实体"></a>Entity实体</h3><hr>
<p>在Cesium中，有几种添加实体的方式，例如利用Entity添加，以及Primitive添加。后者更接近渲染引擎底层所以今天先不介绍。Cesium中利用Entity可以添加许多形状：点、线、面、管道、圆柱体等等，在Cesium官网的<a target="_blank" rel="noopener" href="https://sandcastle.cesium.com/index.html?src=Box.html&label=Geometries">Sandcastle</a>中都有对应的例子，有需要的可以自行查看。</p>
<h4 id="点Billboard"><a href="#点Billboard" class="headerlink" title="点Billboard"></a>点<code>Billboard</code></h4><p>在Cesium中，点的是通过<code>Billboard</code>的方式呈现的，顾名思义就是广告牌。<code>Billboard</code>会在指定坐标位置生成一个面朝屏幕的指定图片。话不多说，我们通过代码来了解一下：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><code class="hljs js">viewer.<span class="hljs-property">entities</span>.<span class="hljs-title function_">add</span>(&#123;<br>    <span class="hljs-attr">position</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-title function_">fromDegrees</span>(<span class="hljs-number">121.54035</span>, <span class="hljs-number">38.92146</span>,<span class="hljs-number">100</span>),<br>    <span class="hljs-attr">billboard</span>: &#123;<br>      <span class="hljs-attr">image</span>: <span class="hljs-built_in">require</span>(<span class="hljs-string">&quot;@/views/images/blueCamera.png&quot;</span>), <span class="hljs-comment">// default: undefined</span><br>      <span class="hljs-attr">show</span>: <span class="hljs-literal">true</span>, <span class="hljs-comment">// default</span><br>      <span class="hljs-attr">pixelOffset</span>: <span class="hljs-keyword">new</span> <span class="hljs-title class_">Cesium</span>.<span class="hljs-title class_">Cartesian2</span>(<span class="hljs-number">0</span>, -<span class="hljs-number">50</span>), <span class="hljs-comment">// default: (0, 0)</span><br>      <span class="hljs-attr">eyeOffset</span>: <span class="hljs-keyword">new</span> <span class="hljs-title class_">Cesium</span>.<span class="hljs-title class_">Cartesian3</span>(<span class="hljs-number">0.0</span>, <span class="hljs-number">0.0</span>, <span class="hljs-number">0.0</span>), <span class="hljs-comment">// default</span><br>      <span class="hljs-attr">horizontalOrigin</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">HorizontalOrigin</span>.<span class="hljs-property">CENTER</span>, <span class="hljs-comment">// default</span><br>      <span class="hljs-attr">verticalOrigin</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">VerticalOrigin</span>.<span class="hljs-property">BOTTOM</span>, <span class="hljs-comment">// default: CENTER</span><br>      <span class="hljs-attr">scale</span>: <span class="hljs-number">2.0</span>, <span class="hljs-comment">// default: 1.0</span><br>      <span class="hljs-attr">color</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Color</span>.<span class="hljs-property">LIME</span>, <span class="hljs-comment">// default: WHITE</span><br>      <span class="hljs-attr">rotation</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Math</span>.<span class="hljs-property">PI_OVER_FOUR</span>, <span class="hljs-comment">// default: 0.0</span><br>      <span class="hljs-attr">alignedAxis</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-property">ZERO</span>, <span class="hljs-comment">// default</span><br>      <span class="hljs-attr">width</span>: <span class="hljs-number">100</span>, <span class="hljs-comment">// default: undefined</span><br>      <span class="hljs-attr">height</span>: <span class="hljs-number">25</span>, <span class="hljs-comment">// default: undefined</span><br>    &#125;,<br>&#125;);<br></code></pre></td></tr></table></figure>

<p>可以看到在这里我们用了<code>Viewer</code>下<code>entities</code>下的一个方法<code>add</code>，entity通过这个方法添加到<code>viewer</code>内。</p>
<p>我在坐标转换的时候给了它一点高程值，以便显示的更完整。效果如下</p>
<p><img src="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/773e0178f68546a8b6b41bba82392299~tplv-k3u1fbpfcp-watermark.image" srcset="/img/loading.gif" lazyload alt="1.gif"></p>
<h4 id="线Polyline"><a href="#线Polyline" class="headerlink" title="线Polyline"></a>线<code>Polyline</code></h4><p>同<code>Billboard</code>一样，线也是通过<code>viewer.add()</code>方法进行添加的。接下来先放代码：</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><code class="hljs js">viewer.<span class="hljs-property">entities</span>.<span class="hljs-title function_">add</span>(&#123;<br>        <span class="hljs-comment">// name:entity.name,</span><br>    <span class="hljs-attr">polyline</span>: &#123;<br>      <span class="hljs-attr">positions</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-title function_">fromDegreesArray</span>([<span class="hljs-number">121.534575</span>,<span class="hljs-number">38.926131</span>, <span class="hljs-number">121.537579</span>,<span class="hljs-number">38.92543</span>,<span class="hljs-number">121.541784</span>,<span class="hljs-number">38.924578</span>,<span class="hljs-number">121.543973</span>,<span class="hljs-number">38.924144</span>,<span class="hljs-number">121.545947</span>,<span class="hljs-number">38.923944</span>]),<br>      <span class="hljs-attr">width</span>: <span class="hljs-number">2</span>,<br>      <span class="hljs-attr">material</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Color</span>.<span class="hljs-property">DARKORANGE</span>.<span class="hljs-title function_">withAlpha</span>(<span class="hljs-number">0.7</span>),<br>      <span class="hljs-comment">// clampToGround: true,</span><br>      <span class="hljs-comment">// show: true,</span><br>    &#125;,<br>&#125;);<br></code></pre></td></tr></table></figure>

<p><code>positions</code>需要一个笛卡尔做表集用来绘制线，<code>width</code>是线宽，<code>material</code>是线的材质（它就是我们生成动效线的关键），<code>clamToGround</code>是选择线是否贴地渲染，在有地形的底图上贴地模式会贴着地形起伏进行绘制，而绝对高度则会穿过地形，最后的<code>show</code>就是是否显示了。</p>
<p>基本效果（为了显示效果好，换了一个深色底图）</p>
<p><img src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/467e77a280b34a81a5fb67d62c2373b7~tplv-k3u1fbpfcp-watermark.image" srcset="/img/loading.gif" lazyload alt="2.gif"></p>
<p>这时候你可能就说了，这个线也太丑了吧，我看人家的线都是那种发光的（你说的是奥特曼吗？这个世界上真的有奥特曼吗？）。别急，接下来我提供一种实现发光的思路，当然思路不仅于此，感兴趣的小伙伴可以多上网搜搜。上代码！</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><code class="hljs js"><span class="hljs-comment">// 在上边添加过的线基础上我们再添加一条动效线</span><br>viewer.<span class="hljs-property">entities</span>.<span class="hljs-title function_">add</span>(&#123;<br>        <span class="hljs-comment">// name:entity.name,</span><br>    <span class="hljs-attr">polyline</span>: &#123;<br>      <span class="hljs-attr">positions</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-title function_">fromDegreesArray</span>([<br>        <span class="hljs-number">121.534575</span>,<br>        <span class="hljs-number">38.926131</span>,<br>        <span class="hljs-number">121.537579</span>,<br>        <span class="hljs-number">38.92543</span>,<br>        <span class="hljs-number">121.541784</span>,<br>        <span class="hljs-number">38.924578</span>,<br>        <span class="hljs-number">121.543973</span>,<br>        <span class="hljs-number">38.924144</span>,<br>        <span class="hljs-number">121.545947</span>,<br>        <span class="hljs-number">38.923944</span>,<br>      ]),<br>      <span class="hljs-attr">width</span>: <span class="hljs-number">4</span>, <span class="hljs-comment">// 线的宽度，像素为单位</span><br>      <span class="hljs-attr">material</span>: <span class="hljs-keyword">new</span> <span class="hljs-title class_">Cesium</span>.<span class="hljs-title class_">PolylineTrailMaterialProperty</span>(&#123;<br>        <span class="hljs-comment">// 尾迹线材质</span><br>        <span class="hljs-attr">color</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Color</span>.<span class="hljs-property">GOLD</span>,<br>        <span class="hljs-attr">trailLength</span>: <span class="hljs-number">0.4</span>,<br>        <span class="hljs-attr">period</span>: <span class="hljs-number">3.0</span>,<br>      &#125;),<br>    &#125;,<br>&#125;);<br></code></pre></td></tr></table></figure>

<p>效果如下</p>
<p><img src="https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/26b83bdb5dc742c0ae0dc4f028bd11a2~tplv-k3u1fbpfcp-watermark.image" srcset="/img/loading.gif" lazyload alt="3.gif"></p>
<p>一条线看着效果感觉还好，但是如果是下边这种路网效果其实是不错的。</p>
<p><img src="https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/4a7041548c9144548916d2bd990ff272~tplv-k3u1fbpfcp-watermark.image" srcset="/img/loading.gif" lazyload alt="4.gif"></p>
<p>相信聪明的小伙伴已经发现了，诶你添加点，线用的都是add方法而且传递的参数结构基本上都是一个<code>position</code>和一个对应的实体配参。不错，其实我们可以基于这样的结构自己封装一个<code>Entity</code>对象，后续二次进行实体的绘制类和编辑类，这里就不进行说明了。</p>
<h4 id="面Polygon"><a href="#面Polygon" class="headerlink" title="面Polygon"></a>面<code>Polygon</code></h4><p>上边那个图其实已经向我们展示了面元素，你肯定会认为我说的是那个绿色的区域，格局小了！其实那些楼房本质上也是一个个面，只不过我们通过拉伸将他拉伸出了一定高度形成了所谓的面。它的添加方式和点、线一样，我就不多赘述了，直接上代码。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs js">viewer.<span class="hljs-property">entities</span>.<span class="hljs-title function_">add</span>(&#123;<br>    <span class="hljs-attr">polygon</span>: &#123;<br>      <span class="hljs-attr">hierarchy</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-title function_">fromDegreesArray</span>([<br>        <span class="hljs-number">121.539208</span>,<br>        <span class="hljs-number">38.924962</span>,<br>        <span class="hljs-number">121.539176</span>,<br>        <span class="hljs-number">38.924737</span>,<br>        <span class="hljs-number">121.540195</span>,<br>        <span class="hljs-number">38.924486</span>,<br>        <span class="hljs-number">121.540281</span>,<br>        <span class="hljs-number">38.924737</span>,<br>      ]),<br>      <span class="hljs-attr">extrudedHeight</span>: <span class="hljs-number">50</span>,<br>      <span class="hljs-attr">material</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Color</span>.<span class="hljs-property">WHITE</span>,<br>      <span class="hljs-comment">// closeTop: false,</span><br>      <span class="hljs-comment">// closeBottom: false,</span><br>    &#125;,<br>&#125;);<br></code></pre></td></tr></table></figure>
<p>看效果：</p>
<p><img src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/2cc8cf3450d84f5386fce77650bc375a~tplv-k3u1fbpfcp-watermark.image" srcset="/img/loading.gif" lazyload alt="5.gif"></p>
<p>这只是生成建筑的一种方式，同样，这也是面众多用途中的一种，我只负责抛砖，大家才是玉。</p>
<h3 id="点击获取面、广告牌"><a href="#点击获取面、广告牌" class="headerlink" title="点击获取面、广告牌"></a>点击获取面、广告牌</h3><p>在项目中我们不可能只是将这些点线面呈现在眼前，我们的要素上一定承载着对应的数据或属性，我们需要通过点击对应要素获取到数据、属性或自定义的操作。</p>
<p>我们先通过<code>ScreenSpaceEventHandler</code>注册一个全局<code>handler</code>，然后利用<code>setInputAction</code>注册<code>LEFT_CLICK</code>鼠标左键点击事件，在它的回调中我们可以获取到鼠标的点击对象。然后通过<code>viewer.scene.pick</code>方法（<code>场景拾取，返回在场景中该窗口位置对应的第一个图元对象，如果该位置没有任何物体则返回undefined</code>），传入坐标，获取到点击位置的实体。</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs js"><br>handler = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Cesium</span>.<span class="hljs-title class_">ScreenSpaceEventHandler</span>(viewer.<span class="hljs-property">scene</span>.<span class="hljs-property">canvas</span>);<br>handler.<span class="hljs-title function_">setInputAction</span>(<span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> &#123;<br>    <span class="hljs-keyword">var</span> pick = viewer.<span class="hljs-property">scene</span>.<span class="hljs-title function_">pick</span>(e.<span class="hljs-property">position</span>);<br>    <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(e , pick);<br>&#125;, <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">ScreenSpaceEventType</span>.<span class="hljs-property">LEFT_CLICK</span>);<br><br></code></pre></td></tr></table></figure>


<p><img src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/951f125ebf7740dfbe6e8eaf60f273ff~tplv-k3u1fbpfcp-watermark.image" srcset="/img/loading.gif" lazyload alt="6.gif"></p>
<p>我们来看看打印出了什么</p>
<p><img src="https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e419d7fa2d634df3ba07e647c7b72f05~tplv-k3u1fbpfcp-watermark.image" srcset="/img/loading.gif" lazyload alt="image.png"></p>
<p><code>e</code>为我们鼠标在屏幕上的屏幕二维坐标组，<code>pick</code>则是返回的图元对象，其中的<code>id</code>则是我们拾取到的实体。</p>
<h3 id="完整代码"><a href="#完整代码" class="headerlink" title="完整代码"></a>完整代码</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br></pre></td><td class="code"><pre><code class="hljs js">&lt;template&gt;<br>  <span class="language-xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;container&quot;</span>&gt;</span></span><br><span class="language-xml">    <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;cesiumContainer&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span><br><span class="language-xml">  <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span><br>&lt;/template&gt;<br><br><span class="language-xml"><span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="language-javascript"></span></span><br><span class="language-javascript"><span class="language-xml"><span class="hljs-keyword">var</span> viewer, camera, handler;</span></span><br><span class="language-javascript"><span class="language-xml"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> &#123;</span></span><br><span class="language-javascript"><span class="language-xml">  <span class="hljs-title function_">data</span>(<span class="hljs-params"></span>) &#123;</span></span><br><span class="language-javascript"><span class="language-xml">    <span class="hljs-keyword">return</span> &#123;&#125;;</span></span><br><span class="language-javascript"><span class="language-xml">  &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">  <span class="hljs-title function_">mounted</span>(<span class="hljs-params"></span>) &#123;</span></span><br><span class="language-javascript"><span class="language-xml">    <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">init</span>();</span></span><br><span class="language-javascript"><span class="language-xml">  &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">  <span class="hljs-attr">methods</span>: &#123;</span></span><br><span class="language-javascript"><span class="language-xml">    <span class="hljs-title function_">init</span>(<span class="hljs-params"></span>) &#123;</span></span><br><span class="language-javascript"><span class="language-xml">      viewer = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Cesium</span>.<span class="hljs-title class_">Viewer</span>(<span class="hljs-string">&quot;cesiumContainer&quot;</span>, &#123;&#125;);</span></span><br><span class="language-javascript"><span class="language-xml">      <span class="hljs-keyword">var</span> layer = viewer.<span class="hljs-property">imageryLayers</span>.<span class="hljs-title function_">addImageryProvider</span>(</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-keyword">new</span> <span class="hljs-title class_">Cesium</span>.<span class="hljs-title class_">UrlTemplateImageryProvider</span>(&#123;</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">url</span>:</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-string">&quot;https://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/&#123;z&#125;/&#123;y&#125;/&#123;x&#125;&quot;</span>,</span></span><br><span class="language-javascript"><span class="language-xml">        &#125;)</span></span><br><span class="language-javascript"><span class="language-xml">      );</span></span><br><span class="language-javascript"><span class="language-xml">      <span class="hljs-comment">//   初始化场景位置</span></span></span><br><span class="language-javascript"><span class="language-xml">      viewer.<span class="hljs-property">scene</span>.<span class="hljs-property">camera</span>.<span class="hljs-title function_">flyTo</span>(&#123;</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-comment">// 初始化相机经纬度</span></span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-attr">destination</span>: <span class="hljs-keyword">new</span> <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-title function_">fromDegrees</span>(</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-number">121.54035</span>,</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-number">38.92146</span>,</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-number">2000</span></span></span><br><span class="language-javascript"><span class="language-xml">        ),</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-attr">orientation</span>: &#123;</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">heading</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Math</span>.<span class="hljs-title function_">toRadians</span>(<span class="hljs-number">0.0</span>),</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">pitch</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Math</span>.<span class="hljs-title function_">toRadians</span>(-<span class="hljs-number">25.0</span>), <span class="hljs-comment">//从上往下看为-90</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">roll</span>: <span class="hljs-number">0</span>,</span></span><br><span class="language-javascript"><span class="language-xml">        &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">      &#125;);</span></span><br><span class="language-javascript"><span class="language-xml"></span></span><br><span class="language-javascript"><span class="language-xml">      handler = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Cesium</span>.<span class="hljs-title class_">ScreenSpaceEventHandler</span>(viewer.<span class="hljs-property">scene</span>.<span class="hljs-property">canvas</span>);</span></span><br><span class="language-javascript"><span class="language-xml">      handler.<span class="hljs-title function_">setInputAction</span>(<span class="hljs-function">(<span class="hljs-params">e</span>) =&gt;</span> &#123;</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-keyword">var</span> pick = viewer.<span class="hljs-property">scene</span>.<span class="hljs-title function_">pick</span>(e.<span class="hljs-property">position</span>);</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-variable language_">console</span>.<span class="hljs-title function_">log</span>(e, pick);</span></span><br><span class="language-javascript"><span class="language-xml">      &#125;, <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">ScreenSpaceEventType</span>.<span class="hljs-property">LEFT_CLICK</span>);</span></span><br><span class="language-javascript"><span class="language-xml"></span></span><br><span class="language-javascript"><span class="language-xml">      <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">addBillboard</span>();</span></span><br><span class="language-javascript"><span class="language-xml">      <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">addPolyline</span>();</span></span><br><span class="language-javascript"><span class="language-xml">      <span class="hljs-variable language_">this</span>.<span class="hljs-title function_">addPolygon</span>();</span></span><br><span class="language-javascript"><span class="language-xml">    &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">    <span class="hljs-title function_">addBillboard</span>(<span class="hljs-params"></span>) &#123;</span></span><br><span class="language-javascript"><span class="language-xml">      viewer.<span class="hljs-property">entities</span>.<span class="hljs-title function_">add</span>(&#123;</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-attr">position</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-title function_">fromDegrees</span>(<span class="hljs-number">121.54035</span>, <span class="hljs-number">38.92146</span>, <span class="hljs-number">50</span>),</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-attr">billboard</span>: &#123;</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">image</span>: <span class="hljs-built_in">require</span>(<span class="hljs-string">&quot;./images/blueCamera.png&quot;</span>), <span class="hljs-comment">// default: undefined</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// show: true, // default</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// pixelOffset: new Cesium.Cartesian2(0, -50), // default: (0, 0)</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// eyeOffset: new Cesium.Cartesian3(0.0, 0.0, 0.0), // default</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// horizontalOrigin: Cesium.HorizontalOrigin.CENTER, // default</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// verticalOrigin: Cesium.VerticalOrigin.BOTTOM, // default: CENTER</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// scale: 2.0, // default: 1.0</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// color: Cesium.Color.LIME, // default: WHITE</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// rotation: Cesium.Math.PI_OVER_FOUR, // default: 0.0</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// alignedAxis: Cesium.Cartesian3.ZERO, // default</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// width: 100, // default: undefined</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// height: 25, // default: undefined</span></span></span><br><span class="language-javascript"><span class="language-xml">        &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">      &#125;);</span></span><br><span class="language-javascript"><span class="language-xml">    &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">    <span class="hljs-title function_">addPolyline</span>(<span class="hljs-params"></span>) &#123;</span></span><br><span class="language-javascript"><span class="language-xml">      viewer.<span class="hljs-property">entities</span>.<span class="hljs-title function_">add</span>(&#123;</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-attr">polyline</span>: &#123;</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">positions</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-title function_">fromDegreesArray</span>([</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.534575</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.926131</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.537579</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.92543</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.541784</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.924578</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.543973</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.924144</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.545947</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.923944</span>,</span></span><br><span class="language-javascript"><span class="language-xml">          ]),</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">width</span>: <span class="hljs-number">4</span>,</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">material</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Color</span>.<span class="hljs-property">DARKORANGE</span>.<span class="hljs-title function_">withAlpha</span>(<span class="hljs-number">0.3</span>),</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// clampToGround: true,</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// show: true,</span></span></span><br><span class="language-javascript"><span class="language-xml">        &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">      &#125;);</span></span><br><span class="language-javascript"><span class="language-xml">      viewer.<span class="hljs-property">entities</span>.<span class="hljs-title function_">add</span>(&#123;</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-comment">// name:entity.name,</span></span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-attr">polyline</span>: &#123;</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">positions</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-title function_">fromDegreesArray</span>([</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.534575</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.926131</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.537579</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.92543</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.541784</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.924578</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.543973</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.924144</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.545947</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.923944</span>,</span></span><br><span class="language-javascript"><span class="language-xml">          ]),</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">width</span>: <span class="hljs-number">4</span>, <span class="hljs-comment">// 线的宽度，像素为单位</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">material</span>: <span class="hljs-keyword">new</span> <span class="hljs-title class_">Cesium</span>.<span class="hljs-title class_">PolylineTrailMaterialProperty</span>(&#123;</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-comment">// 尾迹线材质</span></span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-attr">color</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Color</span>.<span class="hljs-property">GOLD</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-attr">trailLength</span>: <span class="hljs-number">0.4</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-attr">period</span>: <span class="hljs-number">3.0</span>,</span></span><br><span class="language-javascript"><span class="language-xml">          &#125;),</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// clampToGround: true,</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// show: true,</span></span></span><br><span class="language-javascript"><span class="language-xml">        &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">      &#125;);</span></span><br><span class="language-javascript"><span class="language-xml">    &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">    <span class="hljs-title function_">addPolygon</span>(<span class="hljs-params"></span>) &#123;</span></span><br><span class="language-javascript"><span class="language-xml">      viewer.<span class="hljs-property">entities</span>.<span class="hljs-title function_">add</span>(&#123;</span></span><br><span class="language-javascript"><span class="language-xml">        <span class="hljs-attr">polygon</span>: &#123;</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">hierarchy</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Cartesian3</span>.<span class="hljs-title function_">fromDegreesArray</span>([</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.539208</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.924962</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.539176</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.924737</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.540195</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.924486</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">121.540281</span>,</span></span><br><span class="language-javascript"><span class="language-xml">            <span class="hljs-number">38.924737</span>,</span></span><br><span class="language-javascript"><span class="language-xml">          ]),</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">extrudedHeight</span>: <span class="hljs-number">50</span>,</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-attr">material</span>: <span class="hljs-title class_">Cesium</span>.<span class="hljs-property">Color</span>.<span class="hljs-property">WHITESMOKE</span>,</span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// closeTop: false,</span></span></span><br><span class="language-javascript"><span class="language-xml">          <span class="hljs-comment">// closeBottom: false,</span></span></span><br><span class="language-javascript"><span class="language-xml">        &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">      &#125;);</span></span><br><span class="language-javascript"><span class="language-xml">    &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">  &#125;,</span></span><br><span class="language-javascript"><span class="language-xml">&#125;;</span></span><br><span class="language-javascript"><span class="language-xml"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span></span><br><br><span class="language-xml"><span class="hljs-tag">&lt;<span class="hljs-name">style</span> <span class="hljs-attr">lang</span>=<span class="hljs-string">&quot;scss&quot;</span> <span class="hljs-attr">scoped</span>&gt;</span></span><br><span class="language-xml"><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span></span><br></code></pre></td></tr></table></figure>

<h3 id="最后"><a href="#最后" class="headerlink" title="最后"></a>最后</h3><p>最基本的Cesium相关操作通过这几篇文章就大概介绍完了，我的砖也抛出来了，接下来就需要大家自己进行玉的雕琢了。后续我还会整理关于点、面的点击以及简易的封装几个常用功能的类。大家可以多多交流共同进步，毕竟我也是一个Cesium的初学者^-^。</p>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/Cesium/" class="category-chain-item">Cesium</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/JavaScript/">#JavaScript</a>
      
        <a href="/tags/Cesium/">#Cesium</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（三）</div>
      <div>https://moewang0321.github.io/2021/05/05/【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（三）/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Moe Wang</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2021年5月5日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2021/05/23/%E3%80%90%E4%B8%89%E7%BB%B4GIS%E5%8F%AF%E8%A7%86%E5%8C%96%E3%80%91%E5%9F%BA%E4%BA%8EVue+Cesium+Supermap%E5%AE%9E%E7%8E%B0%E6%99%BA%E6%85%A7%E5%9F%8E%E5%B8%82%EF%BC%88%E5%9B%9B%EF%BC%89/" title="【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（四）">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（四）</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2021/04/25/%E3%80%90%E4%B8%89%E7%BB%B4GIS%E5%8F%AF%E8%A7%86%E5%8C%96%E3%80%91%E5%9F%BA%E4%BA%8EVue+Cesium+Supermap%E5%AE%9E%E7%8E%B0%E6%99%BA%E6%85%A7%E5%9F%8E%E5%B8%82%EF%BC%88%E4%BA%8C%EF%BC%89/" title="【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（二）">
                        <span class="hidden-mobile">【三维GIS可视化】基于Vue+Cesium+Supermap实现智慧城市（二）</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  
  
    <article id="comments" lazyload>
      
    <div id="giscus" class="giscus"></div>
    <script type="text/javascript">
      Fluid.utils.loadComments('#giscus', function() {
        var options = {"repo":"moewang0321/moewang0321.github.io","repo-id":"MDEwOlJlcG9zaXRvcnkyMDEyNDI0NTY=","category":"Show and tell","category-id":"DIC_kwDOC_63WM4CUMsH","theme-light":"light_protanopia","theme-dark":"dark_dimmed","mapping":"pathname","reactions-enabled":1,"emit-metadata":1,"input-position":"top","loading":"lazy","lang":"zh-CN"};
        var attributes = {};
        for (let option in options) {
          if (!option.startsWith('theme-')) {
            var key = option.startsWith('data-') ? option : 'data-' + option;
            attributes[key] = options[option];
          }
        }
        var light = 'light_protanopia';
        var dark = 'dark_dimmed';
        window.GiscusThemeLight = light;
        window.GiscusThemeDark = dark;
        attributes['data-theme'] = document.documentElement.getAttribute('data-user-color-scheme') === 'dark' ? dark : light;
        for (let attribute in attributes) {
          var value = attributes[attribute];
          if (value === undefined || value === null || value === '') {
            delete attributes[attribute];
          }
        }
        var s = document.createElement('script');
        s.setAttribute('src', 'https://giscus.app/client.js');
        s.setAttribute('crossorigin', 'anonymous');
        for (let attribute in attributes) {
          s.setAttribute(attribute, attributes[attribute]);
        }
        var ss = document.getElementsByTagName('script');
        var e = ss.length > 0 ? ss[ss.length - 1] : document.head || document.documentElement;
        e.parentNode.insertBefore(s, e.nextSibling);
      });
    </script>
    <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
